package com.think.service;

import org.apache.tomcat.util.security.MD5Encoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * Created by Administrator on 2018/5/22 0022.
 */
public class MD5PasswordEncoder implements PasswordEncoder {
    private static final Logger logger = LoggerFactory.getLogger(MD5PasswordEncoder.class);

    @Override
    public String encode(CharSequence charSequence) {
        return MD5Encoder.encode(((String) charSequence).getBytes());
    }

    @Override
    public boolean matches(CharSequence charSequence, String s) {
        String encryptedPassword = MD5Encoder.encode(((String) charSequence).getBytes());
        return encryptedPassword.equals(s);
    }
}
